from base import session, User
split = "\n####################\n"

for instance in session.query(User).order_by(User.id):
    print(type(instance))
    print(instance.name, instance.fullname)

print(split)

for name, fullname in session.query(User.name, User.fullname):
    print(name, fullname)

print(split)

for row in session.query(User, User.name).all():
    print(row.User, row.name)

print(split)

for row in session.query(User.name.label('name_label')).all():
    print(row.name_label)


print(split)

from sqlalchemy.orm import aliased
user_alias = aliased(User, name='user_alias')
for row in session.query(user_alias, user_alias.name).all():
    print(row.user_alias)

print(split)
for u in session.query(User).order_by(User.id)[1:3]:
    print(u)

print(split)
for name, in session.query(User.name).filter_by(fullname='Ed Jones'):
    print(name)

print(split)

for user in session.query(User).filter(User.name=='ed').filter(User.fullname=='Ed Jones'):
    print(user)
